/*
* $Id: ConvertData.java 258 2011-01-30 19:56:15Z volok-aleksej@yandex.ru $
*
* Copyright 2008-2011 by Volokitin Alexey
* All rights reserved
*
*/
package apiary.db.managers;

import apiary.db.FamilyStore.FamilyRecord;
import apiary.db.FieldsValueStore.FieldsValueRecord;
import apiary.db.HousingStore.HousingRecord;
import apiary.db.InspectStore.InspectRecord;
import apiary.db.JournalStore.JournalRecord;
import apiary.db.PointStore.PointRecord;
import apiary.db.QueenBeeStore.QueenBeeRecord;
import apiary.db.UserFieldsStore.UserFieldsRecord;
import apiary.ui.journal.FamilyForm.FamilyValue;
import apiary.ui.journal.HousingForm.HousingValue;
import apiary.ui.journal.InspectValue;
import apiary.ui.journal.JournalForm.JournalValue;
import apiary.ui.journal.PointForm.PointValue;
import apiary.ui.journal.QueenBeeForm.QueenBeeValue;
import apiary.ui.journal.UserFieldForm.UserField;

/**
 * Converts some data to other
 * @author lexus
 */
public class ConvertData
{
    /**
     * Converts data of point form to database point record
     * @param value data of point form
     * @param record database point record
     */
    public static void PointValueToRecord(PointValue value, PointRecord record) {
        record.namePoint = value.namePoint;
        record.notePoint = value.notePoint;
    }

    /**
     * Converts database point record to data of point form
     * @param value data of point form
     * @param record database point record
     */
    public static void PointRecordToValue(PointRecord record, PointValue value) {
        value.namePoint = record.namePoint;
        value.notePoint = record.notePoint;
    }
    
    /**
     * Converts database user's fields value record to data of user field form
     * @param record database user's fields value record
     * @param value data of user field form
     */
    public static void FieldsValueToUserField(FieldsValueRecord record, UserField value) {
        value.nameField = record.nameField;
        value.typeField = record.typeField;
        value.valueField = record.valueField;
    }
    
    /**
     * Converts data of user field form to database user's fields value record
     * @param record database user's fields value record
     * @param value data of user field form
     */
    public static void UserFieldToFieldsValue(UserField value, FieldsValueRecord record) {
        record.nameField = value.nameField;
        record.typeField = value.typeField;
        record.valueField = value.valueField;
    }

    /**
     * Converts database user's fields record to data of user field form
     * @param record database user's fields record
     * @param value data of user field form
     */
    public static void UserFieldsToUserField(UserFieldsRecord record, UserField value) {
        value.nameField = record.nameField;
        value.typeField = record.typeField;
    }

    /**
     * Converts data of family form to database family record
     * @param value data of family form
     * @param record database family record
     */
    public static void FamilyValueToRecord(FamilyValue value, FamilyRecord record) {
        record.idPoint = value.idPoint;
        record.name = value.nameFamily;
        record.typeFamily = value.typeFamily;
        record.noteFamily = value.noteFamily;
    }

    /**
     * Converts database family record to data of family form
     * @param value data of family form
     * @param record database family record
     */
    public static void FamilyRecordToValue(FamilyRecord record, FamilyValue value) {
        value.idPoint = record.idPoint;
        value.nameFamily = record.name;
        value.typeFamily = record.typeFamily;
        value.noteFamily = record.noteFamily;
    }

    /**
     * Converts data of housing form to database housing record
     * @param value data of housing form
     * @param record database housing record
     */
    public static void HousingValueToRecord(HousingValue value, HousingRecord record) {
        record.idFamily = value.idFamily;
        record.name = value.nameHousing;
        record.typeFrames = value.typeFrames;
        record.typeHousing = value.typeHousing;
        record.isDelete = value.isDelete;
    }

    /**
     * Converts database housing record to data of housing form
     * @param value data of housing form
     * @param record database housing record
     */
    public static void HousingRecordToValue(HousingRecord record, HousingValue value) {
        value.idFamily = record.idFamily;
        value.nameHousing = record.name;
        value.typeFrames = record.typeFrames;
        value.typeHousing = record.typeHousing;
        value.isDelete = record.isDelete;
    }

    /**
     * Converts data of queen bee form to database queen bee record
     * @param value data of queen bee form
     * @param record database queen bee record
     */
    public static void QueenBeeValueToRecord(QueenBeeValue value, QueenBeeRecord record) {
        record.idFamily = value.idFamily;
        record.idParentQueenBee = value.idParentQueenBee;
        record.nameQueenBee = value.nameQueenBee;
        record.breed = value.breed;
        record.date = value.date;
        record.fert = value.fert;
        record.description = value.description;
        record.isDead = value.isDead;
    }

    /**
     * Converts database queen bee record to data of queen bee form
     * @param value data of queen bee form
     * @param record database queen bee record
     */
    public static void QueenBeeRecordToValue(QueenBeeRecord record, QueenBeeValue value) {
        value.idFamily = record.idFamily;
        value.idParentQueenBee = record.idParentQueenBee;
        value.nameQueenBee = record.nameQueenBee;
        value.breed = record.breed;
        value.date = record.date;
        value.fert = record.fert;
        value.description = record.description;
        value.isDead = record.isDead;
    }

    /**
     * Converts database common inspect record to data of journal form
     * @param value data of journal form
     * @param record database common inspect record
     */
    public static void JournalValueToRecord(JournalValue value, JournalRecord record) {
        record.date = value.date;
        record.frame = value.frame;
        record.strength = value.strength;
        record.ambrosia = value.ambrosia;
        record.is_queen_bee = value.isQB;
        record.dieting = value.dieting;
        record.disease = value.disease;
        record.wax = value.wax;
        record.noteJournal = value.note;
    }

    /**
     * Converts data of journal form to database common inspect record
     * @param value data of journal form
     * @param record database common inspect record
     */
    public static void JournalRecordToValue(JournalRecord record, JournalValue value) {
        value.date = record.date;
        value.frame = record.frame;
        value.strength = record.strength;
        value.ambrosia = record.ambrosia;
        value.isQB = record.is_queen_bee;
        value.dieting = record.dieting;
        value.disease = record.disease;
        value.wax = record.wax;
        value.note = record.noteJournal;
    }
    
    /**
     * Converts database hive's inspect record to data of inspect form
     * @param value data of inspect form
     * @param record database hive's inspect record
     */
    public static void InspectValueToRecord(InspectValue value, InspectRecord record) {
        record.idHousing = value.idHousing;
        record.nameHousing = value.nameHousing;
        record.honey = value.honey;
        record.brood = value.brood;
        record.openBrood = value.openBrood;
        record.closeBrood = value.closeBrood;
        record.goodsHoney = value.goodsHoney;
   }

    /**
     * Converts data of inspect form to database hive's inspect record
     * @param value data of inspect form
     * @param record database hive's inspect record
     */
    public static void InspectRecordToValue(InspectRecord record, InspectValue value) {
        value.idHousing = record.idHousing;
        value.nameHousing = record.nameHousing;
        value.honey = record.honey;
        value.brood = record.brood;
        value.openBrood = record.openBrood;
        value.closeBrood = record.closeBrood;
        value.goodsHoney = record.goodsHoney;
    }
}
